﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.WebPages;

namespace Kugar.MVC.MobileUI.WeUI.PageControls
{
    public interface IMobileUIElement
    {
        Dictionary<string, string> Attributes { get; }
    }

    public interface IMobileUIElement_Container : IMobileUIElement, IDisposable
    {
        //IAdminControl_Container Render();
    }

    public abstract class MobileUIElementBase : IMobileUIElement
    {
        private ViewContext _viewContext = null;
        private Lazy<TagAttrbute> _attr = new Lazy<TagAttrbute>(attrLazy);

        internal TagAttrbute _attrs { get { return _attr.Value; } }

        internal MobileUIElementBase(ViewContext viewContext)
        {
            _viewContext = viewContext;
        }

        public Dictionary<string, string> Attributes => _attrs.Attributes;



        protected ViewContext ViewContext => _viewContext;

        private static TagAttrbute attrLazy()
        {
            return new TagAttrbute();
        }

        protected HtmlHelper Html => ((WebViewPage)WebPageContext.Current.Page).Html;

        protected AjaxHelper Ajax => ((WebViewPage)WebPageContext.Current.Page).Ajax;

        protected MobileUI WebUI => (MobileUI)_viewContext.ViewBag.MobileUI;
    }

    public abstract class MobileUIElement_ContainerBase : MobileUIElementBase, IMobileUIElement_Container
    {
        protected MobileUIElement_ContainerBase(ViewContext viewContext) : base(viewContext)
        {
        }

        public abstract void Dispose();

        internal abstract IMobileUIElement_Container RenderInternal();

        public override string ToString()
        {
            return "请调用Render函数输出范围";
            return base.ToString();
        }
    }


    public class MobileUI
    {
        
    }
}